﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Snake
{
    class GameRender
    {
        public void ClearConsole()
        {
            Console.Clear();
        }

        public void RenderField(Field f)
        {
            for(int i = 0; i < f.Width; i++)
            {
                Console.SetCursorPosition(i, 0);
                Console.Write("x");                     
            }

            for (int j = 0; j < f.Height; j++)
            {
                Console.SetCursorPosition(0, j);
                Console.Write("x");
            }
            for(int i = f.Width; i>= 0; i--)
            {
                Console.SetCursorPosition(i, f.Height);
                Console.Write("x");                     
            }
            for (int j = 0; j < f.Height; j++)
            {
                Console.SetCursorPosition(f.Width, j);
                Console.Write("x");
            }
        }

        public void RenderSnake(Snake s)
        {            
            for (int i = 0; i < s.SnakeBody.Count ; i++)
            {
                Snake.SnakeItem item = s.SnakeBody[i];
                Console.SetCursorPosition(item.X, item.Y);
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Write("0");
                Console.ResetColor();
            }
        }

        public void RenderFoodOnConsole(Food f)
        {
            Console.SetCursorPosition(f.X, f.Y);
            Console.Write("*");
        }
    }
}
